<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        var removeDuplicates = function (s) {
            let stack=[]
            stack.push(s[0])
            let m = s.length
            let i=1
            while(i<m){
                if (stack[stack.length-1]!=s[i]){
                    stack.push(s[i++])
                }else{
                    stack.pop()
                    i++
                }
            }
            return stack.join('')
        };
        console.log(removeDuplicates('aababbasdebfsf'))
    </script>
</body>

</html>